package com.zone.domain.strategy.model.entity;

import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @author: zongzi
 * @description: 策略
 * @date: 2024/5/20
 */
@Builder
@Data
public class StrategyEntity {
    /** 抽奖策略ID */
    private Long strategyId;
    /** 抽奖策略描述 */
    private String strategyDesc;
    /** 规则模型，rule配置的模型同步到此表，便于使用 */
    private String ruleModels;

    /**
     * 解析规则模型
     *
     * @return 返回字符串集合【rule_weight,rule_blacklist】
     */
    public List<String> parseRuleModels() {
        if (StringUtils.isBlank(ruleModels)) {
            return Lists.newArrayList();
        }
        String[] ruleModelArray = StringUtils.split(ruleModels, ",");
        return Arrays.asList(ruleModelArray);
    }
}
